import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '',
    component: () => import('@/views/index'),
    children: [
      {
        path: '/',
        component: () => import('@/views/article-list')
      },
      {
        path: '/add',
        component: () => import('@/views/add')
      }
    ]
  },
  {
    path: '/index',
    redirect: '/'
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login')
  },
  {
    path: '/register',
    name: 'register',
    component: () => import('@/views/register')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
